package hu.myai.util;

import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

/**
 * Static contains for the application. If you need environment specific
 * constants than you need to execute the loadConfig(String configName) method
 * during the initialization. This method overwrite the static variables to the
 * xml values.
 * 
 * you need to create setter in order to use loadConfig
 * 
 * @author bozbalint
 * 
 */
public class Constans {

    public static String proxyHost = null; // "proxy.lsy.bud.dlh.de";

    public static int proxyPort = 3128;

    public static String dateFormat = "yyyy-MM-dd";

    public static String[] symbols = { "BHP", "CFU", "FMS" };

    public static String scenarioPath = "xml/scenarios/";

    public static String utilPath = "xml/util/";
    
    public static String dataPath = "data/forexite/";

    /*
     * bean factories
     */
    public static XmlBeanFactory ctx_Dummy = new XmlBeanFactory(new ClassPathResource(scenarioPath
            + "Scenario_Dummy_spring.xml"));

    public static XmlBeanFactory ctx_StrangeSwing = new XmlBeanFactory(new ClassPathResource(scenarioPath
            + "StrangeSwing_spring.xml"));

//    public static XmlBeanFactory ctx_AllBull = new XmlBeanFactory(new ClassPathResource(scenarioPath
//            + "AllBullish_spring.xml"));
    
    /*
     * setters
     */

    /**
     * @param proxyHost
     *            the proxyHost to set
     */
    public void setProxyHost(String proxyHost) {
        Constans.proxyHost = proxyHost;
    }

    /**
     * @param proxyPort
     *            the proxyPort to set
     */
    public void setProxyPort(int proxyPort) {
        Constans.proxyPort = proxyPort;
    }

    /**
     * @param dateFormat
     *            the dateFormat to set
     */
    public void setDateFormat(String dateFormat) {
        Constans.dateFormat = dateFormat;
    }

    /**
     * @param symbols
     *            the symbols to set
     */
    public void setSymbols(String[] symbols) {
        Constans.symbols = symbols;
    }

    /**
     * @param scenarioPath
     *            the scenarioPath to set
     */
    public void setScenarioPath(String scenarioPath) {
        Constans.scenarioPath = scenarioPath;
    }

    /**
     * @param utilPath
     *            the utilPath to set
     */
    public void setUtilPath(String utilPath) {
        Constans.utilPath = utilPath;
    }

    public void setDataPath(String dataPath) {
		Constans.dataPath = dataPath;
	}

	public Constans() {
    }

    /**
     * If you need environment specific constants than you need to execute the
     * loadConfig(String configName) method during the initialization. This
     * method overwrite the static variables to the xml values.
     * 
     **/
    public static void loadConfig(String fileName) {

        XmlBeanFactory ctx_Constans = new XmlBeanFactory(new ClassPathResource(fileName));

        @SuppressWarnings("unused")
        Constans constans = (Constans) ctx_Constans.getBean("myaiConstans");
    }
}
